package com.ruoyi.web.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.WebUserBase;
import com.ruoyi.web.service.IWebUserBaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 网站用户 Controller
 * 
 * @author derek
 * @date 2021-04-17
 */
@RestController
@RequestMapping("/web/webuser")
public class WebUserBaseController extends BaseController
{
    @Autowired
    private IWebUserBaseService webUserBaseService;

    /**
     * 查询网站用户 列表
     */
    @PreAuthorize("@ss.hasPermi('web:webuser:list')")
    @GetMapping("/list")
    public TableDataInfo list(WebUserBase webUserBase)
    {
        startPage();
        List<WebUserBase> list = webUserBaseService.selectWebUserBaseList(webUserBase);
        return getDataTable(list);
    }

    /**
     * 导出网站用户 列表
     */
    @PreAuthorize("@ss.hasPermi('web:webuser:export')")
    @Log(title = "网站用户 ", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WebUserBase webUserBase)
    {
        List<WebUserBase> list = webUserBaseService.selectWebUserBaseList(webUserBase);
        ExcelUtil<WebUserBase> util = new ExcelUtil<WebUserBase>(WebUserBase.class);
        return util.exportExcel(list, "网站用户 数据");
    }

    /**
     * 获取网站用户 详细信息
     */
    @PreAuthorize("@ss.hasPermi('web:webuser:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(webUserBaseService.selectWebUserBaseById(id));
    }

    /**
     * 新增网站用户 
     */
    @PreAuthorize("@ss.hasPermi('web:webuser:add')")
    @Log(title = "网站用户 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WebUserBase webUserBase)
    {
        return toAjax(webUserBaseService.insertWebUserBase(webUserBase));
    }

    /**
     * 修改网站用户 
     */
    @PreAuthorize("@ss.hasPermi('web:webuser:edit')")
    @Log(title = "网站用户 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WebUserBase webUserBase)
    {
        return toAjax(webUserBaseService.updateWebUserBase(webUserBase));
    }

    /**
     * 删除网站用户 
     */
    @PreAuthorize("@ss.hasPermi('web:webuser:remove')")
    @Log(title = "网站用户 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(webUserBaseService.deleteWebUserBaseByIds(ids));
    }
}
